using System.Windows.Forms;
using HogoLogic;

namespace ProjectView
{
	public partial class ProjectListControl : UserControl
	{
		public ProjectListControl()
		{
			InitializeComponent();
		}

		internal void ShowProjects(HogoProjectList projects)
		{
			if (projects != null)
				foreach (HogoProject project in projects)
				{
					ListViewItem projectListViewItem = new ListViewItem();
					projectListViewItem.Text = project.Name;
					projectListViewItem.ImageIndex = 0;
					projectListViewItem.Tag = project;

					projectsListView.Items.Add(projectListViewItem);
				}
		}

		internal HogoProject SelectedProject
		{
			get
			{
				if (projectsListView.SelectedItems.Count > 0)
					return projectsListView.SelectedItems[0].Tag as HogoProject;
				else
					return null;
			}
		}
	}
}
